package com.pengchuang.ACS.admin.boot.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pengchuang.ACS.admin.api.dto.UserAuthDTO;
import com.pengchuang.ACS.admin.boot.entity.SysUser;
import com.pengchuang.ACS.admin.boot.service.ISysUserService;
import com.pengchuang.ACS.common.utils.R;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/v1/users")
@Slf4j
@RequiredArgsConstructor
public class UserController {

    private final ISysUserService iSysUserService;

    /**
     * 获取用户信息
     */
    @GetMapping("/username/{username}")
    public R getUserByUsername(@PathVariable String username) {
        UserAuthDTO user = iSysUserService.getByUsername(username);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("result", user);
        return R.ok(map);
    }


    /**
     * 获取用户信息
     */
    @GetMapping("/userId/{userId}")
    public R getUserByUserId(@PathVariable String userId) {
        SysUser user = iSysUserService.getById(userId);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("result", user);
        return R.ok(map);
    }

}